home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / echsys10.zip / ECHOSYS.DOC < prev    next >
Text File  |  1989-09-25  |  10KB  |  231 lines

  1.  
  2.                    E C H O S Y S  /  E N V S Y S  1.0
  3.                    ==================================
  4.  
  5.                        TapirSoft Gisbert W.Selke
  6.                              September 1989
  7.  
  8.  
  9. This is sort of an enhancement to the DOS ECHO and SET commands. In
  10. addition to echoing a string to StdOut or setting an environment
  11. variable, various information about the system may be included
  12. according to the user's wishes, e.g., current drive/directory, date and
  13. time, free memory, DOS and BIOS version, and many others. In addition,
  14. a DOS error level is set to reflect the latest of actions, where
  15. possible.
  16.  
  17.  
  18. There are two main reasons for wanting this: for logging purposes, and
  19. for passing system information to programmes or to environment
  20. variables. Nearly all this information is available one way or the other
  21. via standard DOS commands (DATE, VER, CHKDSK, ...); unfortunately, it is
  22. invariably bundled up with other text, so that it is hard to get at the
  23. main information. (Ever tried to record the current drive/directory in
  24. order to be able to switch back later? Yes, it's possible, but it's
  25. roundabout at best.)
  26.  
  27.  
  28. EchoSys will just copy its command line to StdOut, unless it encounters
  29. its special marker, by default '^'. The character right after this
  30. marker tells EchoSys what sort of information to include before
  31. resuming normal processing. Note that EchoSys by itself appends no
  32. carriage return/line feed at the end of the string - you'll have to do
  33. that yourself (cf. example below).
  34.  
  35.  
  36. E.g., to create a batch file that records the current drive and
  37. directory in environment variables, you might say
  38.  
  39.       echosys  set drive=^:^x0d^x0a>savedir.bat
  40.       echosys  set   dir=^\^x0d^x0a>>savedir.bat
  41.  
  42. Executing SAVEDIR.BAT will now record the pertinent data in the
  43. environment variables given.
  44.  
  45. Note, in the example above, the hex codes that work out as the usual
  46. line terminator bytes.
  47.  
  48. A simpler, equivalent script runs as follows:
  49.  
  50.       echosys  set drive=^:^x0d^x0aset dir=^\>savedir.bat
  51.  
  52. We can leave off the final carriage return/linefeed, because DOS does
  53. not need them. (Neither does it need a Ctrl-Z at the end of a file.)
  54.  
  55. An example for logging system usage is the following line, included in a
  56. batch file that starts some programme:
  57.  
  58.       echosys MapView started on ^W, ^D^/^M, at ^h^-^m\x0d\x0a
  59.  
  60. Again, note the use of the line end bytes.
  61.  
  62.  
  63. For the status of LPT1, '^L', several bits are added as follows:
  64.  
  65.  1 time out       8 I/O error      16 selected       32 out of paper
  66. 64 acknowledge  128 not busy
  67.  
  68.  
  69. The sequence '^K' is slightly different: the user is expected to type a
  70. single letter, which is inserted into the output before the rest of the
  71. line is processed. Only ASCII letters are accepted; extended keys (like
  72. function or cursor keys) are ignored.
  73.  
  74.  
  75. Wherever possible, EchoSys sets a DOS error level equalling the
  76. numerical value of the last special sequence output; e.g., after '^:'
  77. the error level will be 67, the ASCII code for 'C', if and only if the
  78. current disk is drive C:. In some cases, this will be meaningless; in
  79. particular, '^\' does not affect the error level, '^F' and '^T' will
  80. return a value in 1000 KN, which may not be much use, and so forth. The
  81. PC type, command '^t', will be a code as follows:
  82.  
  83. 0 unknown     1 Model 80    2 Ap          3 Model 30    4 unknown
  84. 5 AT          6 PC Junior   2 XT          3 PC
  85.  
  86. Of the currency symbol, '^$', only the first character will be returned.
  87. An important way to use this feature, however, is for prompts in menus,
  88. e.g.,
  89.  
  90.       echosys It is now ^h^-^m. Enter your choice (A/B/C): ^K Thank you.
  91.  
  92. On return, the error level will be set to the ASCII value of the key
  93. typed by the user (note that the values of the earlier commands in the
  94. line will be discarded in favour of the last one). A batch file would
  95. now proceed to take action based on that error level. Keep in mind that
  96. the input is case significant, so you might want to check for both 65
  97. and 97 to catch 'A' and 'a', etc.
  98.  
  99.  
  100. A complete list of the special designators follows:
  101.  
  102. : current drive                         \ current directory
  103. F free disk space (in KBytes)           T total disk space (in KBytes)
  104. R free RAM (in KBytes)                  r RAM size (in KBytes)
  105. l number of logical drives              f number of floppies installed
  106. P number of parallel printer ports      S number of communication ports
  107. 7 is coprocessor installed? (0 or 1)    V current video mode
  108. w screen width                          t type of PC
  109. v DOS version                           b BIOS version
  110. i "<" symbol                            o ">" symbol
  111. p "|" symbol                            O options char (switch char)
  112. x character given by next 2 hex digits  K key typed by user
  113. D day                                   M month
  114. Y year                                  W weekday
  115. h hour                                  m minute
  116. s second                                c centisecond
  117. / date separator                        - time separator
  118. k 1000s separator                       1 decimal separator
  119. C country code                          $ currency string
  120. L LPT1 status
  121.  
  122.  
  123. Note that the command designator is case-dependent.
  124.  
  125.  
  126. Any other character will be passed through unaltered; in particular, the
  127. sequence '^^' will put one '^' into the output.
  128.  
  129.  
  130. Calling EchoSys without any parameters (and I mean *without*, i.e., even
  131. without a trailing blank) will display a short help screen, so that you
  132. don't need to remember all those cryptic designators.
  133.  
  134.  
  135. EnvSys works very much alike, but does not output anything (as long as
  136. it is called with at least one parameter), but sends all its output to
  137. an environment variable instead. The name of this variable must be the
  138. first argument on the command line. E.g., the drive/directory saving
  139. examples from above may be rewritten as
  140.  
  141.       envsys disk ^:
  142.       envsys drive ^\
  143.  
  144. For many applications, this involves far less overhead than the methods
  145. outlined above; on the other hand, there are things that you just cannot
  146. do in this simpler way. - Note that there is no '=' between the variable
  147. name and the string. - An empty string will remove the variable from the
  148. environment; again, 'empty' is to be taken seriously. The environment is
  149. checked for availability of room; no harm will be done in any case, but
  150. no error condition is indicated to the user. (You can easily check for
  151. success by examining the contents of the variable in question.)
  152.  
  153.  
  154. If you are in a subordinate command shell, EnvSys will update both the
  155. subordinate and the primary shell's environments, but not those of any
  156. further intermediate shells that may lurk in the shadows.
  157.  
  158.  
  159. Depending on the DOS version you use, some of the features may not work
  160. properly; all this has been tested under MS-DOS 3.3. I wouldn't
  161. recommend running it under DOS 1.x, though.
  162.  
  163.  
  164. I have chosen the character '^' as a marker because it is rarely used
  165. for other purposes (as opposed to, say, the more common '\'). If you
  166. discover that you dislike my choice, you can either re-assemble with
  167. the marker of your choosing (look for the definition of 'special'), or
  168. you can directly patch EchoSys.Com with Debug or your favourite binary
  169. editor; look for the string 'SPECIAL=' near the beginning of the file
  170. and change the character right behind.
  171.  
  172.  
  173. Two notes on style:
  174.  
  175. (i) Yeah, I know this utility is kind of crammy. It's not meant to be
  176. used regularly from the command line, though; it's lean and mean and
  177. it's for use in batch files where you once think about it and then
  178. forget it. I tried to put in everything I could think of, so that I
  179. need just one utility instead of dozens. (If I've forgotten something
  180. you need, tell me...)
  181.  
  182. (ii) The assembler code is probably bad style, spaghetti and so forth.
  183. Sorry about that; I'm not an assembler programmer at all.
  184.  
  185.  
  186. Legal stuff:
  187.  
  188. Debug, DOS and its offspring are copyrighted by MicroSoft Corp.
  189.  
  190. Writing this wouldn't have been possible were it not for Ralf Brown's
  191. excellent list of the interrupts used by